package com.lhy.xiancheng;
//通过继承创建线程
public class GuessANumber extends Thread {
    private int number;
    public GuessANumber(int number){
        this.number = number;
    }
    //因为是继承所以要创建
    public void run(){
        int counter = 0;
        int guess = 0;
        do {
            guess = (int)(Math.random()*100+1);
            System.out.println(this.getName()+"guesses"+guess);
            counter++;
        }while (guess != number);
        System.out.println("**Correct!"+this.getName()+"in"+counter+"guesses.**");
    }
}
